# !/usr/bin/env python
# -*- coding:utf-8 -*-
# @FileName : zsj.py
# @Time     : 2024/4/10 21:48
# @Author   : Robot-Zsj
"""
description:

input
4
cat
bt
hat
tree
atach??
output
3
"""

n = int(input())

words = []

for i in range(n):
    words.append(input())

chars = input()


def charStatistic(s):
    cnts = [0] * 128

    for c in s:
        cnts[ord(c)] += 1

    return cnts


def getResult():
    ans = 0

    cnt_chars = charStatistic(chars)

    for word in words:
        diff = 0

        cnt_word = charStatistic(word)

        for j in range(128):
            diff += max(cnt_word[j] - cnt_chars[j], 0)

        if diff <= cnt_chars[ord('?')]:
            ans += 1

    return ans


print(getResult())
